---
apiVersion: v1
kind: Pod
metadata:
  name: fabriccli
  namespace: "{{ namespace }}"
  labels:
    k8s-app: fabriccli
spec:
{% if fabric.repo.username | default('') | length > 0 and fabric.repo.password | default('')| length > 0 %}
  imagePullSecrets:
  - name: regcred
{% endif %}
  restartPolicy: Never
  volumes:
    - name: task-pv-storage
      persistentVolumeClaim:
        claimName: fabriccerts
  containers:
    - name: fabriccli
      image: {{ fabric.repo.url }}fabric-tools:{{ fabric.baseimage_tag }}
{% if fabric.baseimage_tag == 'latest' or 'stable' in fabric.baseimage_tag %}
      imagePullPolicy: Always
{% else %}
      imagePullPolicy: IfNotPresent
{% endif %}
      env:
{% if project_version is version('1.3.0','<') %}
        - name: "CORE_LOGGING_LEVEL"
          value: "DEBUG"
{% elif project_version is version('1.4.0','>=') or 'stable' in project_version or 'latest' in project_version %}
        - name: "FABRIC_LOGGING_SPEC"
          value: "DEBUG"
{% endif %}
      volumeMounts:
        - mountPath: /etc/hyperledger/fabric/artifacts
          name: task-pv-storage
      command: ["/etc/hyperledger/fabric/artifacts/dochannel.sh"]
